<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('修改文件资源')" />
    <th:block th:include="include :: bootstrap-fileinput-css" />
</head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-file-edit" th:object="${businessFile}">
            <input name="id" th:field="*{id}" type="hidden">
            <div class="form-group">
                <label class="col-sm-2 control-label is-required">文件名:</label>
                <div class="col-sm-8">
                    <input name="fileName" th:field="*{fileName}" class="form-control" type="text" required>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-2 control-label is-required">历史文件</label>
                <div class="col-sm-9">
                    <input name="filePath" id="filePath" th:value="*{filePath}" class="form-control" type="hidden" required>
                    <a th:href="*{filePath}">下载文件</a>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-2 control-label is-required">新文件:</label>
                <div class="col-sm-9">
                    <label class="font-noraml"></label>
                    <div class="file-loading">
                        <input id="fileinput" type="file" multiple>
                    </div>
                </div>
            </div>
        </form>
    </div>
    <th:block th:include="include :: footer" />
    <th:block th:include="include :: bootstrap-fileinput-js" />
    <script type="text/javascript">
        var prefix = ctx + "businessfile/file";
        $("#form-file-edit").validate({
            focusCleanup: true
        });

        function submitHandler() {
            if ($.validate.form()) {
                $.operate.save(prefix + "/edit", $('#form-file-edit').serialize());
            }
        }

        $(document).ready(function () {
            $("#fileinput").fileinput({
                uploadUrl:prefix + "/addfile",
                uploadAsync:true,
                maxFileCount:1,
                dropZoneTitle:"拖拽文件到这里...<br/>最大文件体积25MB"
            });

            $("#fileinput").on("fileuploaded", function (event, data, previewId, index) {
                $("#filePath").val(data.response.data);
            })

        });
    </script>
</body>
</html>
